import { ref, onMounted } from "vue";
import { getExpensesListAPI, ownerHouseListAPI } from '@/api/expenses'
import { communityListApi, buildingListApi } from "@/api/hooks";
// 收费项目
export const useExpenseProjectList = () => {
  // 收费项目列表
  const expenseProjectList = ref([]);
  // 定义方法
  const getExpenseProjectList = async () => {
    let res = await getExpensesListAPI();
    expenseProjectList.value = res.data;
  };

  onMounted(() => {
    getExpenseProjectList();
  });
  return expenseProjectList;
};

// 所属房产
export const useOwnerHouseList = () => {
  // 收费项目列表
  const ownerHouseList = ref([]);
  // 定义方法
  const getOwnerHouseList = async () => {
    let res = await ownerHouseListAPI();
    ownerHouseList.value = res.data;
  };

  onMounted(() => {
    getOwnerHouseList();
  });
  return ownerHouseList;
};

// 小区名称
export const useCommunityNameList = () => {
  // 小区名列表
  const communityList = ref([]);
  // 定义方法
  const getcommunityList = async () => {
    let res = await communityListApi();
    communityList.value = res.data;
  };

  onMounted(() => {
    getcommunityList();
  });
  return communityList;
};

// 获取楼栋
export const useBuildingList = (code) => {
  const BuildingList = ref([]);
  const getAllBuildingList = async () => {
    // code='CM-8c63d562-199e-4dd2-b08c-55b271a00769'
    const res = await buildingListApi(code);
    BuildingList.value = res.data;
  };
  onMounted(() => {
    getAllBuildingList();
  });
  return BuildingList;
};




